export function formatDate(numb, format) {
  const time = new Date((numb - 1) * 24 * 3600000 + 1)
  time.setYear(time.getFullYear() - 70)
  const year = time.getFullYear() + ''
  const month = time.getMonth() + 1 + ''
  const date = time.getDate() - 1 + ''
  if (format && format.length === 1) {
    return year + format + month + format + date
  }
  return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date)
}

export function timeFilters(type) {   //时间

  var time = new Date(type);

  var year = time.getFullYear(); //年

  var month = (time.getMonth() + 1 + "").padStart(2, "0"); //月

  var date = (time.getDate() + "").padStart(2, "0"); //日

  var hour = (time.getHours() + "").padStart(2, "0"); //时

  var minutes = (time.getMinutes() + "").padStart(2, "0"); //分

  var seconds = (time.getSeconds() + "").padStart(2, "0"); //秒

  return `${year}-${month}-${date} ${hour}:${minutes}:${seconds}`
}

export function titleFilters(val) {
  val === '1'? '启用' : '禁用'
}

export function timeTrans(time){
  var json_date = new Date(time).toJSON()
  return new Date(+new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
}
